﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace YArchitech.Public.ExcelToView
{
	internal abstract class ExcelLoaderBase
	{
		internal string ExcelPath
		{
			get
			{
				return this.excelPath;
			}
			set
			{
				this.SearchValues.Clear();
				if (!File.Exists(value))
				{
					this.excelPath = null;
					return;
				}
				this.excelPath = value;
			}
		}

		internal List<List<string>> GetExcelValue(List<int> datas, int wantSheetIndex = -1, string wantSheetName = null, string inputPath = null)
		{
			if (!this.LoadExcel(datas, wantSheetIndex, wantSheetName, inputPath))
			{
				return null;
			}
			if (0 <= wantSheetIndex)
			{
				if (this.SearchValues.Keys.Contains(wantSheetIndex))
				{
					return this.SearchValues[wantSheetIndex];
				}
				return null;
			}
			else
			{
				if (wantSheetName != null)
				{
					return this.SearchValues[-this.SearchValues.Count];
				}
				return null;
			}
		}

		internal virtual List<int> RankRolTitle()
		{
			return this.RolRank;
		}

		protected virtual bool LoadExcel(List<int> datas, int wantSheetIndex = -1, string wantSheetName = null, string inputPath = null)
		{
			return false;
		}

		private string excelPath;

		private List<int> RolRank = new List<int>();

		protected Dictionary<int, List<List<string>>> SearchValues = new Dictionary<int, List<List<string>>>();
	}
}
